<!--div class="form-group">
    <label class="col-sm-3 control-label">搜索：</label>

    <div class="col-sm-8">
        <div class="input-group" style="width: 200px;">
            <input type="text" class="form-control" id="taobao">
            <div class="input-group-btn">
                <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                </ul>
            </div>
        </div>
    </div>
</div-->
<script src="__PUBLIC__/admin/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<!-- 搜索配置 -->
    <script type="text/javascript">
        var testBsSuggest = $("#test").bsSuggest({
            url: "js/plugins/suggest/data.json",
            idField: "userId",
            keyField: "userName"
        }).on("onDataRequestSuccess", function (e, result) {
            console.log("onDataRequestSuccess: ", result)
        }).on("onSetSelectValue", function (e, keyword) {
            console.log("onSetSelectValue: ", keyword)
        }).on("onUnsetSelectValue", function (e) {
            console.log("onUnsetSelectValue")
        });
        var testBsSuggest = $("#testNoBtn").bsSuggest({
            url: "js/plugins/suggest/data.json",
            showBtn: false,
            idField: "userId",
            keyField: "userName"
        }).on("onDataRequestSuccess", function (e, result) {
            console.log("onDataRequestSuccess: ", result)
        }).on("onSetSelectValue", function (e, keyword) {
            console.log("onSetSelectValue: ", keyword)
        }).on("onUnsetSelectValue", function (e) {
            console.log("onUnsetSelectValue")
        });
        var testdataBsSuggest = $("#test_data").bsSuggest({
            indexId: 2,
            indexKey: 1,
            data: {
                "value": [{
                        "id": "0",
                        "word": "lzw",
                        "description": "http://lzw.me"
                    }, {
                        "id": "1",
                        "word": "lzwme",
                        "description": "http://w.lzw.me"
                    }, {
                        "id": "2",
                        "word": "meizu",
                        "description": "http://www.meizu.com"
                    }, {
                        "id": "3",
                        "word": "flyme",
                        "description": "http://flyme.meizu.com"
                    }],
                "defaults": "http://lzw.me"
            }
        });
        var baiduBsSuggest = $("#baidu").bsSuggest({
            allowNoKeyword: false,
            multiWord: true,
            separator: ",",
            getDataMethod: "url",
            url: "http://unionsug.baidu.com/su?p=3&t=" + (new Date()).getTime() + "&wd=",
            jsonp: "cb",
            processData: function (json) {
                var i, len, data = {
                        value: []
                    };
                if (!json || !json.s || json.s.length === 0) {
                    return false
                }
                console.log(json);
                len = json.s.length;
                jsonStr = "{'value':[";
                for (i = 0; i < len; i++) {
                    data.value.push({
                        word: json.s[i]
                    })
                }
                data.defaults = "baidu";
                return data
            }
        });
        var taobaoBsSuggest = $("#taobao").bsSuggest({
            indexId: 2,
            indexKey: 1,
            allowNoKeyword: false,
            multiWord: true,
            separator: ",",
            getDataMethod: "url",
            effectiveFieldsAlias: {
                Id: "id",
                Keyword: "关键字",
                Count: "数量"
            },
            showHeader: true,
            //url: "http://www.cl.com/admin/index/suos/?p=",
            url: "http://suggest.taobao.com/sug?code=utf-8&extras=1&q=",
            jsonp: "callback",
            processData: function (json) {
                var i, len, data = {
                        value: []
                    };
                if (!json || !json.result || json.result.length == 0) {
                    return false
                }
                console.log(json);
                len = json.result.length;
                for (i = 0; i < len; i++) {
                    data.value.push({
                        "Id": (i + 1),
                        "Keyword": json.result[i][0],
                        "Count": json.result[i][1]
                    })
                }
                console.log(data);
                return data
            }
        });
        $("form").submit(function (e) {
            return false
        });
    </script>